package com.siburian.MyStuff;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import android.content.Intent;
import android.widget.EditText;

public class AddProfil extends Activity{
	DBProfil prof;
	EditText profileName;
	Button b1;
	public void onCreate(Bundle as){
		super.onCreate(as);
		setContentView(R.layout.add_profil);
		prof = new DBProfil(this);
		b1 =(Button) findViewById(R.id.btnAddProfil);
		profileName = (EditText)findViewById(R.id.txtAddProfil);
		b1.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				tambahProfile();
				Intent i = new Intent(AddProfil.this,ListProfil.class);
				startActivity(i);
			}
		});
	}
	protected void tambahProfile(){
		try {
	prof.addProfile(profileName.getText().toString());
	Toast.makeText(getBaseContext(),profileName.getText().toString() + ", berhasil ditambahkan",
	Toast.LENGTH_SHORT).show();
	} catch (Exception e) {
			e.printStackTrace();
			Toast.makeText(getBaseContext(), "gagal simpan, " + e.toString(),
					Toast.LENGTH_LONG).show();
		}
	}

}
